package com.ironman.analyze.core.handler;

import com.ironman.analyze.core.compute.entity.WindEnvWindowData;
import com.ironman.common.params.WindParam;
import com.ironman.common.util.UnitConvertUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.function.Consumer;

@Slf4j
public class WindPostHandler extends BasePostHandler<WindEnvWindowData> {

    private final WindParam windParam;

    public WindPostHandler(WindParam windParam) {
        this.windParam = windParam;
    }

    @Override
    public void handler(WindEnvWindowData data, Consumer<WindEnvWindowData> consumer) {
        doHandler(data, consumer);
    }

    @Override
    public void threshold(WindEnvWindowData data) {
        Double customWindSpeed = windParam.getCustomWindSpeed();
        Integer customWindDirection = windParam.getCustomWindDirection();

        data.setCustomWindSpeed(UnitConvertUtil.unitConvert(customWindSpeed, windParam.getSpeedUnit()));
        data.setCustomWindDirection(customWindDirection);
    }

}
